/* DEFINE VARIABLE voutput AS CHARACTER  NO-UNDO initial "\\192.168.12.12\shared$\output\csv\". */
/* define VARIAble vdb     like ad_name_control initial "".                                     */
/*                                                                                              */
/* find code_mstr NO-LOCK WHERE code_fldname = "exptab2csv" and code_value = "output" no-error. */
/* if avail code_mstr then do:                                                                  */
/*     assign voutput = code_cmmt.                                                              */
/* end.                                                                                         */
/*                                                                                              */
/* for first ad_mstr no-lock where ad_addr = "~~reports".                                       */
/* end.                                                                                         */
/* if avail ad_mstr then do:                                                                    */
/*     assign vdb = ad_name_control .                                                           */
/* end.                                                                                         */
/*                                                                                              */
/* output to value(voutput + vdb + "emp_mstr.csv").                                             */

output to value({1} + {2} + "emp_mstr.csv").

FOR EACH emp_mstr NO-LOCK WHERE  emp_status = "AC" :

    put {2} ","
        emp_addr format "x(12)" ","""
        emp_lname ""","""
        emp_fname ""","""
        emp_line1 ""","""
        emp_line2 ""","""
        emp_city  ""","""
        emp_state ""","""
        emp_zip ""","""
        emp_country ""","""
        emp_phone ""","""
        emp_bs_phone ""","""
        emp_ext ""","""
        emp_ssn """,".
        if emp_birthday = ? then do:
            put ",".
        end.
        else do:
            put string(year(emp_birthday),"9999") + "-" + string(month(emp_birthday),"99") + "-" + string(day(emp_birthday),"99") format "x(10)" ",".
        end.
        if emp_emp_date = ? then do:
            put ",".
        end.
        else do:
            put string(year(emp_emp_date),"9999") + "-" + string(month(emp_emp_date),"99") + "-" + string(day(emp_emp_date),"99") format "x(10)" ",".
        end.
        if emp_trm_date = ? then do:
            put ",".
        end.
        else do:
            put string(year(emp_trm_date),"9999") + "-" + string(month(emp_trm_date),"99") + "-" + string(day(emp_trm_date),"99") format "x(10)" ",".
        end.
        put emp_status ","
        emp_freq ","
        emp_pay_type ","
        emp_pay_rate ","
        emp_marital ","
        emp_exempt ","
        emp_wk_loc ","
        emp__qad01 ","
        emp__qad02 ","
        emp_project ","
        emp_dept ","
        emp_units ","
        emp_sick_hrs ","
        emp_vac_hrs ","
        emp_title ","
        emp_wc_class ","
        emp_last_pay ",".
        if emp_last_dt = ? then do:
            put ",".
        end.
        else do:
            put string(year(emp_last_dt),"9999") + "-" + string(month(emp_last_dt),"99") + "-" + string(day(emp_last_dt),"99") format "x(10)" ",".
        end.
        put 
        emp_line3 ","
        emp_user1 ","
        emp_user2 ","
        emp_user3 ","
        emp_user4 ","
        emp_user5 ",".
        if emp_user6 = ? then do:
            put ",".
        end.
        else do:
            put string(year(emp_user6),"9999") + "-" + string(month(emp_user6),"99") + "-" + string(day(emp_user6),"99") format "x(10)" ",".
        end.
        put
        emp_bank ","
        emp_ad_bank ","
        emp_ad_acc1 ","
        emp_ad_amt1 ","
        emp_ad_pct1 ","
        emp_ad_acc2 ","
        emp_ad_amt2 ","
        emp_ad_pct2 ","
        emp__chr01 ","
        emp__chr02 ","
        emp__chr03 ","
        emp__chr04 ","
        emp__chr05 ",".
        if emp__dte01 = ? then do:
            put ",".
        end.
        else do:
            put string(year(emp__dte01),"9999") + "-" + string(month(emp__dte01),"99") + "-" + string(day(emp__dte01),"99") format "x(10)" ",".
        end.
        if emp__dte02 = ? then do:
            put ",".
        end.
        else do:
            put string(year(emp__dte02),"9999") + "-" + string(month(emp__dte02),"99") + "-" + string(day(emp__dte02),"99") format "x(10)" ",".
        end.
         if emp__dte03 = ? then do:
            put ",".
        end.
        else do:
            put string(year(emp__dte03),"9999") + "-" + string(month(emp__dte03),"99") + "-" + string(day(emp__dte03),"99") format "x(10)" ",".
        end.
        if emp__dte04 = ? then do:
            put ",".
        end.
        else do:
            put string(year(emp__dte04),"9999") + "-" + string(month(emp__dte04),"99") + "-" + string(day(emp__dte04),"99") format "x(10)" ",".
        end.
        if emp__dte05 = ? then do:
            put ",".
        end.
        else do:
            put string(year(emp__dte05),"9999") + "-" + string(month(emp__dte05),"99") + "-" + string(day(emp__dte05),"99") format "x(10)" ",".
        end.
        put
        emp__dec01 format "->>>>>>>>>>9.9<" ","
        emp__dec02 format "->>>>>>>>>>9.9<" ","
        emp__log01 ","
        emp__log02 ",".
        if emp_mod_date  = ? then do:
            put ",".
        end.
        else do:
            put string(year(emp_mod_date),"9999") + "-" + string(month(emp_mod_date),"99") + "-" + string(day(emp_mod_date),"99") format "x(10)" ",".
        end.
        put
        emp_userid ","
        emp_ad_bank2 ","
        emp_transit1 ","
        emp_transit2 ","
        emp_ad_type1 ","
        emp_ad_type2 ","
        emp_shift ","
        emp_ctry skip.


END.
output close.
